import React from 'react';
import { Link, hashHistory } from 'react-router';

const EditSuccess = React.createClass({
  getInitialState() {
    return {
      time: 3
    };
  },
  componentDidMount() {
    this.timer();
  },
  timer() {
    let i = 3;
    const timer = setInterval(() => {
      i--;
      this.setState({time: i})
      if (i === 0) {
        clearInterval(timer);
        hashHistory.push('/userManage/userInfo');
      }
    }, 1000);

  },
  render() {
    return (
      <div>
        <div className="editpwd-success-content">
          <img src="/static/dist-static/img/success_log.png" alt="" />
          <p className="success-msg">提示登录密码修改成功!</p>
          <p className="mt90">{this.state.time}秒后自动返回 <Link to="/userManage/userInfo" activeClassName="active">账号管理</Link>...</p>
        </div>
      </div>
    );
  }
});

export default EditSuccess;
